Add debug wrappers for str[n]dupt.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 5 Apr 2004 13:59:39 +0000 (13:59 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 5 Apr 2004 13:59:39 +0000 (13:59 +0000)
gpsbabel/defs.h
gpsbabel/util.c

index ffedceb688934eb486b1777e950ec412cb5c44d7..20fd14bef35b1b9b3b790349da5b34dc766c2232 100644 (file)
@@ -380,6 +380,8 @@ void *XMALLOC(size_t size, DEBUG_PARAMS );
 void *XREALLOC(void *p, size_t s, DEBUG_PARAMS );
 void XFREE(void *mem, DEBUG_PARAMS );
 char *XSTRDUP(const char *s, DEBUG_PARAMS );
+char *XSTRNDUP(const char *src, size_t size, DEBUG_PARAMS );
+char *XSTRNDUPT(const char *src, size_t size, DEBUG_PARAMS );
 char *XSTRAPPEND(char *src, const char *new, DEBUG_PARAMS );
 void debug_mem_open();
 void debug_mem_output( char *format, ... );
@@ -389,12 +391,15 @@ void debug_mem_close();
 #define xrealloc(p, s) XREALLOC(p,s,__FILE__,__LINE__)
 #define xfree(mem) XFREE(mem, __FILE__, __LINE__)
 #define xstrdup(s) XSTRDUP(s, __FILE__, __LINE__)
+#define xstrndup(s, z) XSTRNDUP(s, z, __FILE__, __LINE__)
+#define xstrndupt(s, z) XSTRNDUPT(s, z, __FILE__, __LINE__)
 #define xstrappend(src,new) XSTRAPPEND(src, new, __FILE__, __LINE__)
 #define xxcalloc XCALLOC
 #define xxmalloc XMALLOC
 #define xxrealloc XREALLOC
 #define xxfree XFREE
 #define xxstrdup XSTRDUP
+#define xxstrndupt XSTRNDUPT
 #define xxstrappend XSTRAPPEND
 #endif /* DEBUG_MEM */
 
index 9166ca4c42d4af0e5d0d75c4e82990bd65827a11..dfad3fb36f6685ba208c553284283d89a629c956 100644 (file)
@@ -138,7 +138,11 @@ xstrdup(const char *s)
  * Duplicate at most sz bytes in str.
  */
 char *
+#ifdef DEBUG_MEM
+XSTRNDUP(const char *str, size_t sz, DEBUG_PARAMS )
+#else
 xstrndup(const char *str, size_t sz)
+#endif
 {
        size_t newlen;
        char *newstr;
@@ -160,7 +164,11 @@ xstrndup(const char *str, size_t sz)
  * while copying.
  */
 char *
+#ifdef DEBUG_MEM
+XSTRNDUPT(const char *str, size_t sz, DEBUG_PARAMS )
+#else
 xstrndupt(const char *str, size_t sz)
+#endif
 {
        size_t newlen;
        char *newstr;